import { createApp/* , VueElement */ } from 'vue';
import { marked } from 'marked';
import hljs from 'highlightjs';
import App from './App.vue';
import router from './router';
import store from './store';
import typeset from './utils/globalVariable';

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

// marked 选项
marked.setOptions({
  highlight(code) {
    return hljs.highlightAuto(code).value;
  },
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: true,
  xhtml: false,
});

const app = createApp(App);

app.use(store)
  .use(router)
  .use(typeset)
  .component('marked', marked)
  .mount('#app');
